import { defineStore } from 'pinia'
import { store } from '@/store'

const defaultUserInfo = {
  id: '',
  token: '',
  name: '',
  avatar: '',
  roles: [],
}

export const useUserStore = defineStore('user', () => {
  const userInfo = ref({ ...defaultUserInfo })

  return { userInfo }
}, { persist: true })

// 需要在设置之外使用
export function useUserStoreWithOut() {
  return useUserStore(store)
}
